// 2025/4/4
// https://leetcode.cn/problems/reverse-integer/description/
// 整数反转

class Solution {
    public:
        int reverse(int x) {
            int ans = 0;
            while(x != 0)
            {
                if(ans < INT_MIN / 10 || ans > INT_MAX / 10)
                    return 0;
                ans *= 10;
                ans += (x % 10);
                x /= 10;
            }
            return ans;
        }
    };